#include<iostream>
#include<map>
using namespace std;
int main()
{
    map<int,char> mymap;
    char c='a';
    for (int i = 1; i <= 4; i++,c++)
    {
        mymap[i]=c;
    }
    cout<<"mymap:"<<endl;
    map<int,char>::iterator it;
    for (it=mymap.begin(); it!=mymap.end(); it++)
    {
        cout<<it->first<<" "<<it->second<<endl;
    }
    mymap[1]='x';
    cout<<"value of 1="<<mymap[1]<<endl;
    pair<map<int,char>::iterator,bool> ret;//pair对象第一个元素是map的迭代器，第二个是bool变量
    ret=mymap.insert(make_pair(6,'y'));
    if (!ret.second)
    {
        cout<<"element existed:";
        cout<<ret.first->first<<" "<<ret.first->second<<endl;
    }
    for (it=mymap.begin(); it!=mymap.end(); it++)
    {
        cout<<it->first<<" "<<it->second<<endl;
    }
    return 0;
}